package see.battle.test;

import see.battle.Const;
import see.battle.object.Bullet;

import junit.framework.TestCase;

public class BulletTestCase extends TestCase {
  
  long _creationTime;
  long _currentTime;
  long _nextCurrentTime;
  long _nextNextCurrentTime;
  float _shortMovement;
  float _longMovement;

	protected void setUp() throws Exception {
		super.setUp();
    _creationTime = Const.updateDelay * 0;
    _currentTime = Const.updateDelay * 10;
    _nextCurrentTime = Const.updateDelay * (long)((1 - 
        Const.backgroundSeaLevel) / Const.bulletSpeed - 1);
    _nextNextCurrentTime = Const.updateDelay * (long)((1 - 
        Const.backgroundSeaLevel) / Const.bulletSpeed + 1);
    _shortMovement = 1 - Const.bulletSpeed * 10;
    _longMovement = Const.backgroundSeaLevel + Const.bulletSpeed;
	}
	
	public void testBullet() {
    Bullet bullet = new Bullet(null, Const.myBulletType, (float)0.5, null, 
        _creationTime, _currentTime);
		assertEquals(bullet.get_position(), _shortMovement);
		assertEquals(bullet.is_exists(), true);
		bullet.update(_nextCurrentTime);
		assertEquals(bullet.get_position(), _longMovement);
    assertEquals(bullet.is_exists(), true);
    bullet.update(_nextNextCurrentTime);
    assertEquals(bullet.get_position(), Const.backgroundSeaLevel - 
        Const.bulletSpeed);
    assertEquals(bullet.is_exists(), false);
	}
	
}

